<?php
session_start();
if(isset($_SESSION['userid'])&&$_SESSION['level']!=2)
{
	
	header ("location: login.php");
	exit();
}
?>
<?php
include("includes/top_user.php");
?>
<?php
include("includes/connect.php");
if(isset($_POST['ok_them']))
{
	if($_POST['cate_name'] == "" )
	{
		echo "Đại ca nhập giùm em cái tên danh mục ";
	}
	else
	{
		$type_name = $_POST['cate_name'];
	}
	$maloai = $_POST['type'];
	if($type_name && $maloai)
	{
		$sql = "insert into category(cate_name,maloai) values('".$type_name."', '".$maloai."')";
		mysql_query("set names 'utf8'");
		mysql_query($sql);
		header("location: main_manager.php");
		exit();	
	}
	
}
?>
<div id="box">
<h3>Thêm thể loại</h3>
<form action="add_cate.php" method="post">
Tên danh mục : <input type="text" name="cate_name"  /><br />
Thuộc thể loại : <select name="type">
	<?php
    $sql_type = "select * from type_category";
	mysql_query("set names 'utf8'");
    $query_type = mysql_query($sql_type);
    while($row_type = mysql_fetch_array($query_type))
        {	
            echo "<option value=$row_type[maloai]>$row_type[tenloai]</option>";
        }
    ?>
</select><br />

<input type="submit" name="ok_them" value="Thêm danh mục" />
</form>
</div>

<?php
include("includes/sidebar.php");
?>

<?php
include("includes/footer.php");
?>